<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	//显示统计数据
	$chatlog['all']=pdo_count('jy_kefu_chatlog',array('uniacid'=>$_SESSION['uniacid']));
	$chatlog['day']=pdo_count('jy_kefu_chatlog',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>strtotime(date('ymd'))));
	$member['all']=pdo_count('jy_kefu_member',array('uniacid'=>$_SESSION['uniacid']));
	$kefu['web']=pdo_count('jy_kefus',array('uniacid'=>$_SESSION['uniacid'],'type'=>0));
	$kefu['wechat']=pdo_count('jy_kefus',array('uniacid'=>$_SESSION['uniacid'],'type'=>4));
	$kefu['wxapp']=pdo_count('jy_kefus',array('uniacid'=>$_SESSION['uniacid'],'type'=>5));
	$kefus=pdo_getall('jy_kefus',array('uniacid'=>$_SESSION['uniacid'],'plugin'=>0));
	$kefudata=array();
	foreach($kefus as $key=>&$item){
		$kefudata[$key]['name']=$item['nickname'];
		$kefudata[$key]['value']=pdo_count('jy_kefu_chatlog',array('uniacid'=>$_SESSION['uniacid'],'getmid'=>$item['id']));
	}
	$htmls=array(
		array('type'=>'data','num'=>12,'one_num'=>3,'title'=>'聊天数据','datas'=>array(
			array('title'=>'总对话数','num'=>1,'data'=>$chatlog['all']),
			array('title'=>'今日对话数','num'=>1,'data'=>$chatlog['day']),
			array('title'=>'总用户','num'=>1,'data'=>$member['all']),
			array('title'=>'总客服数','num'=>1,'data'=>count($kefus)),
		)),
		array('type'=>'echarts_pie','width'=>'50%','num'=>12,'ecid'=>'wechat','title'=>'客服分布图','datas'=>array(
					'time' => date("Y-m-d H:i:s", time()),
					'datas'=>array(
						array('name'=>'网页客服','value'=>$kefu['web']),
						array('name'=>'微信客服','value'=>$kefu['wechat']),
						array('name'=>'小程序客服','value'=>$kefu['wxapp']),
					),
		)),
		array('type'=>'echarts_pie','width'=>'50%','num'=>12,'ecid'=>'wxapp','title'=>'聊天分布图','datas'=>array(
					'time' => date("Y-m-d H:i:s", time()),
					'datas'=>$kefudata,
		)),
	);
	$return=array('htmls'=>$htmls);
	exi($return);
}